<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
    <nav th:fragment="navbar" class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container-fluid">
            <a class="navbar-brand" th:href="@{/}">MyApp</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/}" th:classappend="${#httpServletRequest.requestURI == '/'} ? 'active'">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/products}" th:classappend="${#httpServletRequest.requestURI.startsWith('/products')} ? 'active'">产品</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</body>
</html>